﻿using ECommerce.Web.Models;
using FluentNHibernate.Conventions;
using FluentNHibernate.Conventions.AcceptanceCriteria;
using FluentNHibernate.Conventions.Inspections;
using FluentNHibernate.Conventions.Instances;

namespace ECommerce.Web.NHibernate.MappingConventions
{
    public class IdConvention : IIdConvention, IIdConventionAcceptance
    {
        public void Accept(IAcceptanceCriteria<IIdentityInspector> criteria)
        {
            criteria.Expect(x => x.EntityType.BaseType == typeof(Entity) && !x.EntityType.IsAbstract);
        }

        public void Apply(IIdentityInstance instance)
        {
            instance.GeneratedBy.HiLo("100");
        }
    }
}
